package csu.rjxyg.action.interceptor;

import java.util.Map;


import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

import csu.rjxyg.action.BaseAction;
import csu.rjxyg.action.constant.UserConstant;
import csu.rjxyg.factory.core.UtilFactory;
import csu.rjxyg.util.LogUtil;

public class CheckIsLogin extends BaseAction implements Interceptor{

	private LogUtil log;
	private Map session;
	
	public CheckIsLogin(){
	}
	
	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		session = this.getSession();
		Object obj = session.get(UserConstant.USER_SESSION);
		if(obj != null){
			return invocation.invoke();
		}

		else{
			return BaseAction.FAIL;
		}
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		log = null;
		session = null;
	}

	@Override
	public void init() {
		// TODO Auto-generated method stub
		log =  UtilFactory.getLogUtil(getClass());
	}

}
